<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../../css/reset.css" />
		<link rel="stylesheet" type="text/css" href="login.css" />
		<title></title>
		<script src="../../../js/jquery-2.2.3.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
		<!--cookie 操作插件-->
		<script src="../../../js/jquery.cookie.js"></script>
		<style type="text/css">
			input {
				border: 0;
				outline: none;
			}
			.titleT{
				height: 1.2rem;
				position: fixed;
				top: 0;
				z-index: 1;
				background-color: #F7F7F7;
				width: 100%;
				box-shadow: 0.069444rem 0.069444rem 0.069444rem #b3b3b3;
			}
			.titleT img{
				width: 0.25rem;
				margin-left: 0.333333rem;
				margin-top: 0.347222rem;
			}
			.titleT span{
				color: #e83023;
				font-size: 16px;
				position: relative;
				top: -0.4rem;
			}
			.titleT p{
				text-align: center;
			}
		</style>
	</head>

	<body>
		<div class="wrapper">
			<div class="titleT">
				<a href="javascript:history.go(-1)"><img src="../../../../common/footer/12.png"/></a>
				<p><span>登陆</span></p>
			</div>
			<div id="logo"><img src="../../../images/login/logo.png" /></div>
			<div class="section sectionF" style="border: 1px solid black; border-radius: 1.111111rem;">
				<div></div>
				<div><img src="../../../images/login/ico_sign_01.png" /><input type="text" name="" id="user" value="" placeholder="用户名" /></div>
				<div></div>
			</div>
			<div class="section sectionF" style="border: 1px solid black; border-radius: 1.111111rem;">
				<div></div>
				<div><img src="../../../images/login/ico_sign_02.png" /><input type="password" name="" id="pwd" value="" placeholder="密码" /></div>
				<div></div>
			</div>
			<div class="section">
				<a href="javascript:void(0);" id="login">
					<div></div>
					<div id="loginBtn">
						<p><span>登</span><span>陆</span></p>
					</div>
					<div></div>
				</a>
			</div>
			<div class="group">
				<a href="javascript:void(0);">忘记密码</a>
				<a href="../register/mynews.html">立即注册</a>
			</div>
			
		</div>
		<script type="text/javascript">
			$(function() {
				console.log($.cookie('tokenRh'));
				var local = 'http://47.104.13.109/member-service';
				$("#loginBtn").on("click", function() {
					var uPattern1 = /^[a-zA-Z0-9]{4,16}$/;
					var uPattern2 = /^[A-Za-z]+[0-9]+[A-Za-z0-9]*|[0-9]+[A-Za-z]+[A-Za-z0-9]*$/g;
					if(!uPattern1.test($("#user").val())) {
						return alert("用户名格式错误");
					}
					//					if (!uPattern2.test($("#pwd").val())) {
					//						return alert("密码必须由6~16个英文字母和数字的字符串组成！");
					//					}
					$.ajax({
						type: "get",
						url: local + '/auth/static-login',
						async: true,
						data: {
							'username': $("#user").val(),
							'password': $("#pwd").val(),
							'remember': 1,
						},
						success: function(res) {
							console.log(res);
							if(res.islogin) {
								//								if($.cookie("tokenRh")){
								$.cookie('tokenReztApp', res.token, {
									expires: 7,
									path: '/'
								});
								$.cookie("tokenRh", res.token, {
									expires: 7,
									path: '/'
								});
								$.cookie('memberId', res.id, {
									expires: 7,
									path: '/'
								});
								$.cookie('roleId', res.roleList[0].id, {
									expires: 7,
									path: '/'
								});
								history.go(-1);
							} else {
								alert("账号或密码错误！！！");
							}
						},
						error: function(error) {
							var errors = JSON.parse(error.responseText);
							console.log(errors)
							errors = errors.error_message.replace(":", "");
							alert('出现错误，请联系系统管理员');
						}
					});
				})
			})
		</script>